#ifndef NETDETECTIONWIDGET_H
#define NETDETECTIONWIDGET_H

#include <QElapsedTimer>
#include <QHostInfo>
#include <QLabel>
#include <QPushButton>
#include <QTcpSocket>
#include <QWidget>
#include "loadingbutton.h"

#define QINT64_MAX 9223372036854775807LL

class NetDetectionWidget : public QWidget
{
    Q_OBJECT
public:
    explicit NetDetectionWidget(QWidget *parent = nullptr);

protected slots:

public slots:
    void onStopCheck();
    void onbtnDetectionClick();

private:
    void checkNetworkConnected();
    void checkTcpServerConnected();
    void resolveDomainName();
    void TcpConnectCost();

private:
    QLabel *detection;
    QLabel *label;
    QLabel *label2;
    LoadingButton *btnDetection;
    QTcpSocket *socket;
    bool networkStatus;
    bool networkconnected;
    bool checkNetworkconnectFinished;
    bool tcpConnectStatus;
    qint64 tcpConnectElasped;

    //bool reloveDomainNameStatus;

    qint64 reloveDomainNameElasped;

    //当还没有检测完毕时就切换，这的逻辑就是停止检测，但是因为我们采用的时定时器检测，并不会停止
    //也就是会弹出检测完毕的窗口，这个窗口是我们发送信号，让settingWidget切换的，因此当我们停止检测时使用一个标志位说明检测
    //停止了，不能发送更换窗口的信号了。
    bool stopCheck;
signals:
    void checkNetworkFinished(bool a, bool b, bool c, qint64 d, qint64 e);
};

#endif // NETDETECTIONWIDGET_H
